package com.example.tms.mapper;

import com.example.tms.bean.AreaInfo;
import com.example.tms.bean.OfficeInfo;
import com.example.tms.bean.OilPrice;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;


@Repository
public interface OilPriceMapper extends JpaRepository<OilPrice,String> , JpaSpecificationExecutor<OilPrice> {





    //查询所有区域信息
    @Query(value = "select * from oil_price where sfcz = true", nativeQuery = true)
    List<OilPrice> findAll();

    //查询所有区域信息
    @Query(value = "select * from oil_price where sfcz = true order by ydjqsrq asc", nativeQuery = true)
    List<OilPrice> findForOrder();

    //删除区域信息（假删除 区域id）
    @Query(value = "update oil_price set  sfcz = false where ydjid = ?1", nativeQuery = true)
    @Modifying
    @Transactional
    void DeleteByYdjid(String ydjid);

    //查询区域信息（区域id）
    OilPrice findByYdjidAndSfcz(String ydjid, boolean sfcz);




    //查询区域信息（区域名称）
    OilPrice findByszrq(String szrq);
}
